<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    String path4 = request.getContextPath();
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <style type="text/css">
        li span {
            margin-left: 0px;
            cursor: pointer;
        }

        li span:hover {
            color: #427dff
        }

        .modal-data5 {
            visibility: hidden;
            z-index: 1001;
            /* width: 100%; */
            min-height: 500px;
            margin: 100px auto;
            background-color: #FFFFFF;
            /* border: 1px solid #C80B14;*/
            -moz-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            -webkit-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            /*         box-shadow:0 0 10px #cccccc;
            box-shadow: #cccccc; */
            box-shadow: 0 10px 20px #57a1ff inset, 0 -10px 0 #57a0ff inset;
            padding: 5px;
            text-align: center;
            position: fixed;
            left: 22%;
        }
    </style>
</head>
<body>
<div id="modal-overlay">

</div>
<div class="modal-data5">
    <div style="height: 60px">
        <ul>
            <li style="text-align: left;margin-left: 60px;height: 40px;line-height: 40px">
                <span style="margin-left: 30px;">名称：</span>
                <span>
				  		 	<input class="coachesName" type="text">
				  		</span>
                <span>
				  			<button  class="findBtn5">
				  				查询
				  			</button>
				  		</span>
            </li>
        </ul>
    </div>

    <div style="width:1000px; height:350px; overflow:scroll;">
        <form action="">
            <table class="head5" id="groupList" style="width: auto;white-space:nowrap;border-spacing: 0px">
                <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
                    <td></td>
                    <td>名称</td>
                    <td>编码</td>
                    <td>简称</td>
                    <td>描述</td>
                    <td>创建时间</td>
                    <td>用户名</td>
                    <td>最后修改时间</td>
                    <td>用户名</td>
                    <td>财务组织</td>
                    <td>单据分录序列号</td>
                    <td>教练</td>
                    <td>组长</td>
                    <td>队长</td>
                    <td>教练队</td>
                    <td>科目</td>
                </tr>

                <c:forEach items="${coacegroups}" var="coacegroup" varStatus="s">
                    <tr class="coacegroup">
                        <td><input class="data2-checkbox" type="checkbox" name="group" style="width: 15px;"
                                   value="${coacegroup.fid}"/>
                        </td>
                        <td>${coacegroup.fnameL2}</td>
                        <td>${coacegroup.fnumber}</td>
                        <td>${coacegroup.fsimplename}</td>
                        <td>${coacegroup.fdescriptionL2}</td>
                        <td>${coacegroup.fcreatetime}</td>
                        <td>${coacegroup.createName}</td>
                        <td>${coacegroup.flastupdatetime}</td>
                        <td>${coacegroup.updateName}</td>
                        <td>${coacegroup.cwzzName}</td>
                        <td>${coacegroup.fseq}</td>
                        <td>${coacegroup.jlName}</td>
                        <td>${coacegroup.zzName}</td>
                        <td>${coacegroup.dzName}</td>
                        <td>${coacegroup.jldName}</td>
                        <c:if test="${coacegroup.kmName==2}">
                            <td>科目二</td>
                        </c:if>
                        <c:if test="${coacegroup.kmName==3}">
                            <td>科目三</td>
                        </c:if>

                    </tr>
                </c:forEach>


            </table>

        </form>
    </div>

    <div class="page" style="display: none;">
        <ul style="border-bottom: none;">
            <li>
                <span class="indexPage2">首页</span>
                <span class="prevPage2">上一页</span>
                <span class="nextPage2">下一页</span>
                <span class="endPage2">尾页</span>
                <input type="hidden" id="totalPage2" value="${pb2}">
                <input type="hidden" id="index2" value="0">
            </li>
        </ul>
    </div>

    <button class="subtn5" id="subtn2" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;left: 250px">
        确定
    </button>
    <button class="btn" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;right: 250px">
        关闭
    </button>


</div>
</body>
<script id="table-template-coaches" type="text/x-handlebars-template">
    {{#isNull sList}}
    <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
        <th style="width: 20px"></th>
        <td></td>
        <td>名称</td>
        <td>编码</td>
        <td>简称</td>
        <td>描述</td>
        <td>创建时间</td>
        <td>用户名</td>
        <td>最后修改时间</td>
        <td>用户名</td>
        <td>财务组织</td>
        <td>单据分录序列号</td>
        <td>教练</td>
        <td>组长</td>
        <td>队长</td>
        <td>教练队</td>
        <td>科目</td>
    </tr>
    {{#each sList}}
    <tr class="coacegroup">
        <td><input class="data2-checkbox" type="checkbox" value="{{fid}}" name="group"/></td>
        <td>{{fnameL2}}</td>
        <td>{{fnumber}}</td>
        <td>{{fsimplename}}</td>
        <td>{{fdescriptionL2}}</td>
        <td>{{fcreatetime}}</td>
        <td>{{createName}}</td>
        <td>{{flastupdatetime}}</td>
        <td>{{updateName}}</td>
        <td>{{cwzzName}}</td>
        <td>{{fseq}}</td>
        <td>{{jlName}}</td>
        <td>{{zzName}}</td>
        <td>{{dzName}}</td>
        <td>{{jldName}}</td>
        {{#compare kmName 2}}
        <td>科目二</td>
        {{/compare}}
        {{#compare kmName 3}}
        <td>科目三</td>
        {{/compare}}
    </tr>
    {{/each}}

    {{else}}
    <td>没有搜索到您想要的内容!</td>
    {{/isNull}}

</script>
<script>
    //弹出框模版文件
    var myTemplatecoach = Handlebars.compile($("#table-template-coaches").html());

    var coachesName = $('.coachesName');

    //点击查找按钮
    $('.findBtn5').click(function () {
        var index = 0;
        $('#groupList').html("<div class='loading'></div>");
        $.ajax({
            url: '<%=path4%>/DrivingSys/getPageCoaceGroup ',
            type: "post",
            data: {
                'pindex': '0',
                'name': coachesName.val(),
            },
            dataType: "json",
            success: function (res) {
                $('#groupList').html(myTemplatecoach(res));
                $('#totalPage2').val(res.pb2);
            },
            error: function () {
                alert('Error');
            }
        });

    })

    $('.indexPage2').click(function () {
        var index = 0
        $('#index2').val(0)
        $.ajax({
            url: '<%=path4%>/DrivingSys/getPageCoaceGroup ',
            type: "post",
            data: {
                'pindex': index,
                'name': coachesName.val(),
            },
            dataType: "json",
            success: function (json) {
                $('#groupList').html(myTemplatecoach(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.endPage2').click(function () {
        var index = parseInt($('#totalPage2').val())
        $('#index2').val(index)
        $.ajax({
            url: '<%=path4%>/DrivingSys/getPageCoaceGroup ',
            type: "post",
            data: {
                'pindex': index,
                'name': coachesName.val(),
            },
            dataType: "json",
            success: function (json) {
                $('#groupList').html(myTemplatecoach(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.nextPage2').click(function () {
        var total = parseInt($('#totalPage2').val())
        if ($('#index2').val() < total) {
            var index = $('#index2').val() - 0 + 1
            $('#index2').val(index)
            $.ajax({
                url: '<%=path4%>/DrivingSys/getPageCoaceGroup ',
                type: "post",
                data: {
                    'pindex': index,
                    'name': coachesName.val(),
                },
                dataType: "json",
                success: function (json) {
                    $('#groupList').html(myTemplatecoach(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经到尾页了！")
        }
    })


    $('.prevPage2').click(function () {
        if ($('#index2').val() != '0') {
            var index = $('#index2').val() - 0 - 1
            $('#index2').val(index)
            $.ajax({
                url: '<%=path4%>/DrivingSys/getPageCoaceGroup ',
                type: "post",
                data: {
                    'pindex': index,
                    'name': coachesName.val(),
                },
                dataType: "json",
                success: function (json) {
                    $('#groupList').html(myTemplatecoach(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经是首页了")
        }
    })
 
</script>
</html>